// Fill out your copyright notice in the Description page of Project Settings.


#include "Food_PickUp1.h"
#include "Engine/StaticMesh.h"
#include "Materials/Material.h"
#include "Components/StaticMeshComponent.h"
#include "UObject/ConstructorHelpers.h"
#include "SurvivalHorrorCharacter.h"

AFood_PickUp1::AFood_PickUp1()
{
	//Set StaticMeshComponent
	ConstructorHelpers::FObjectFinder<UStaticMesh>StaticMesh(TEXT("/Engine/BasicShapes/Cube"));
	if (StaticMesh.Succeeded()) 
		StaticMeshComponent->SetStaticMesh(StaticMesh.Object);
	ConstructorHelpers::FObjectFinder<UMaterial>Material(TEXT("/Game/Textures/FullPickup_Diffuse_Mat"));
	if (Material.Succeeded())
	StaticMeshComponent->SetMaterial(0,Material.Object);
	//Set Food_Pickup Value
	addHunger = 20;
}

void AFood_PickUp1::OnOverLap(UPrimitiveComponent * OverlappedComponent, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
	ASurvivalHorrorCharacter *Character = Cast<ASurvivalHorrorCharacter>(OtherActor);
	if (Character) 
	{
		if (Character->Hunger < 100) 
		{
			Character->Hunger += addHunger;
			Character->Hunger = (Character->Hunger > 100) ? 100 : Character->Hunger;
			Destroy();
		}
	}
}
